<template>
  <el-container>
    <el-header>
      <el-row class="row" :gutter="24">
        <el-col :span="3"
          ><div class="grid-content bg-purple"><h3>电商后台管理</h3></div></el-col
        >
        <el-col :span="18"
          ><div class="grid-content bg-purple-light"><h3>十三先生</h3></div></el-col
        >
        <el-col :span="3"
          ><div class="grid-content bg-purple">
            <el-button type="info" @click='fan'>退出</el-button>
          </div></el-col
        >
      </el-row>
    </el-header>
    <el-container>
      
      <el-aside :width="iss?'60px':'200px'">
        <p class="kai" @click="iss=!iss">|||</p>
        <el-menu
        :unique-opened='true'
          :collapse='iss'
          :collapse-transition='false'
          default-active="$route-path"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :router='true'
        >
        
          <el-submenu :index="item1.id+''" v-for="item1 in list" :key='item1.id'>
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{item1.authName}}</span>
            </template>
            <el-menu-item :index="'/'+item2.path" v-for='item2 in item1.children' :key='item2.id'>
              <i class="el-icon-menu"></i>
              <span slot="title">{{item2.authName}}</span>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
       <router-view></router-view>
     
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import {Power} from '@/http/api'
export default {
   data(){
     return{
       iss:false,
       list:[]
     }
   },
   created(){
      this.getPower()
      // console.log(this.getPower);
   },
   methods:{
     //给返回按钮定义点击事件
     fan(){
       sessionStorage.removeItem('token')
       this.$router.push('/login')

     },
     //调用接口请求数据
     async getPower(){
        const res=await Power()
        console.log(res);
        this.list=res
        
     }
    // getPower(){
    //   Power().then(res=>{
    //     console.log('请求数据',res);
    //     this.list=res
    //   })
    // }
   }
};
</script>
<style scoped>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
}
.row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
  text-align: center;
}
.el-aside {
  /* background-color: #d3dce6; */
  background-color: rgb(84, 92, 100);
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  /* color: aqua;
  text-align: center;
  line-height: 160px;
  font-size: 30px; */
}

.el-container {
  /* margin-bottom: 40px; */
  height: 100%;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-menu{
  border-right: none;
}
.kai{
  height: 10px;
  line-height: 10px;
}
.el-submenu__title {
    font-size: 14px;
    color: #303133;
    padding: 0 60px;
    cursor: pointer;
    transition: border-color .3s,background-color .3s,color .3s;
    box-sizing: border-box;
}
</style>
